﻿
using System.Windows.Threading;
using System;
namespace MediaBrowser.Gui.Tools
{
    public static class CustomExtensions
    {
        /// <summary>
        /// IsImageFile using a predicate, returns true if file
        /// contains .jpg/.png/.bmp
        /// </summary>
        /// <param name="file">file name to check</param>
        public static bool IsImageFile(this string file)
        {
            return
            file.ToUpper().Contains(".jpg".ToUpper()) ||
            file.ToUpper().Contains(".png".ToUpper()) ||
            file.ToUpper().Contains(".bmp".ToUpper());
        }

        public static bool IsMusicFile(this string file)
        {
            return
            file.ToUpper().Contains(".wma".ToUpper()) ||
            file.ToUpper().Contains(".mp3".ToUpper());
        }

        private static Action EmptyDelegate = delegate() { };

        public static void Refresh(this DispatcherObject uiElement)
        {
            uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
        }
    }
}
